#ifndef CIMAGEHELPER_H
#define CIMAGEHELPER_H
#include "common/commonDefFun.h"

namespace libcvos_vfr
{
/**
 * @brief simplest_bgr24_to_bmp (add bmp file header to rgb24 data)
 * @param pSrcBuffer    input rgg24data, without bmp header
 * @param iBufferLen    input data length
 * @param width             input image width
 * @param height            input image height
 * @param pDestBuffer   input and output bmp data buffer, need allocate memory by user
 * @param OutPutLength  output image size
 * @return  0 success, other failed
 */
TOOL_SDK_API int DLL_SPEC simplest_bgr24_to_bmp(unsigned char* pSrcBuffer, int iBufferLen, int width, int height, unsigned char* pDestBuffer, int* OutPutLength);

#ifdef USE_JPEG_LIB

TOOL_SDK_API int DLL_SPEC jpeg_decompress_to_rgb24(unsigned char* pjpgBuffer, int  jpgSize, void** pRGBBuffer, unsigned long* pOutSize, int* outWidth, int* outHeigth);

TOOL_SDK_API int DLL_SPEC rbg24_to_jpeg(unsigned char *srcRGBData,  int  w_Src,  int  h_Src,  void** ppJpegBuffer, unsigned long* pOutSize);

/**
 * @brief do_Stretch_Linear
 * @param w_Dest
 * @param h_Dest
 * @param bit_depth
 * @param src
 * @param w_Src
 * @param h_Src
 * @return
 */
TOOL_SDK_API unsigned char* DLL_SPEC rbg24_Stretch_Linear(unsigned char *srcRGBData,  int w_Src,  int h_Src, int bit_depth, int w_Dest,  int h_Dest);

/**
 * @brief jpeg_decompress_to_bmp
 * @param pjpgBuffer    input jpeg image data
 * @param jpgSize          input jpeg image data size
 * @param pBmpBuffer    output bmp image data, allocate by function, need to be delete[] by user
 * @param pOutSize          output bmp image data size
 * @param outWidth          output bmp image width
 * @param outHeigth         output bmp image height
 * @return  0 success, other failed
 */
TOOL_SDK_API int DLL_SPEC jpeg_decompress_to_bmp(unsigned char* pjpgBuffer, int jpgSize, void** pBmpBuffer, unsigned long* pOutSize, int* outWidth, int* outHeigth);

/**
 * @brief Bmp2Jpeg_Compress
 * @param lpBmpBuffer   input bmp file data
 * @param nWidth            input bmp image width
 * @param nHeight          input bmp image height
 * @param ppJpegBuffer  output jpeg image data, allocate by function, need user to delete[] after
 * @param pOutSize          output jpeg image data length
 * @return  0 success, other failed
 */
TOOL_SDK_API int DLL_SPEC Bmp_to_jpeg(void* lpBmpBuffer,  int  nWidth,  int  nHeight, void** ppJpegBuffer, unsigned long* pOutSize);

TOOL_SDK_API int DLL_SPEC Bmp_to_jpeg_gray(void* lpBmpBuffer,  int  nWidth,  int  nHeight, unsigned char** ppJpegBuffer, unsigned long* pOutSize);

TOOL_SDK_API int DLL_SPEC jpeg_resize_to_bmp(unsigned char* pjpgBuffer, int jpgSize, int  destW,  int  destH,  void** pBmpBuffer, unsigned long* pOutSize);

TOOL_SDK_API int DLL_SPEC jpeg_resize(unsigned char* pjpgBuffer, int jpgSize, int  destW,  int  destH,  void** pOutBuffer, unsigned long* pOutSize);

TOOL_SDK_API int DLL_SPEC bmp_resize(unsigned char* srcBmp, int srcSize,  int  srcW,  int  srcH, void** pOutBuffer, unsigned long* pOutSize,  int destW,  int destH);

TOOL_SDK_API int DLL_SPEC libjpeg_xlwbin_to_jpeg(unsigned char* pBinData, const unsigned  int  width, const unsigned  int  height, unsigned char **ppJpegData, unsigned long* nJpegLen);

TOOL_SDK_API int DLL_SPEC libjpeg_yuv422_to_jpeg(unsigned char* pYUV422Data, const unsigned  int  width, const unsigned  int  height, unsigned char **ppJpegData, unsigned long* nJpegLen);

#endif

#ifdef USE_TURBO_JPEG
TOOL_SDK_API int DLL_SPEC turbo_yuv422_to_jpg(unsigned char *pYUV422Data, const unsigned  int  width, const unsigned  int  height, unsigned char **ppJpegData, unsigned long *nJpegLen);

TOOL_SDK_API int DLL_SPEC turbo_rbg24_to_jpeg(unsigned char *srcRGBData,  int  w_Src,  int  h_Src, unsigned char** ppJpegBuffer, unsigned long* pOutSize);

TOOL_SDK_API int DLL_SPEC turbo_bmp_to_jpg(void* lpBmpBuffer,  int  nWidth,  int  nHeight, unsigned char** ppJpegBuffer, unsigned long* pOutSize);

TOOL_SDK_API int DLL_SPEC turbo_xlw_bin_to_jpg(unsigned char* pBinData, const unsigned  int  width, const unsigned  int height, unsigned char **ppJpegData, unsigned long* nJpegLen);
#endif
}
#endif // CIMAGEHELPER_H
